package com.medical.server.inhospital.controller;

import java.util.Arrays;
import java.util.Map;

import com.laozj.common.utils.PageUtils;
import com.laozj.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.medical.server.inhospital.entity.ApplicationInhospitalEntity;
import com.medical.server.inhospital.service.ApplicationInhospitalService;


/**
 * 
 *
 * @author laozj
 * @email laozj@medical.com
 * @date 2024-09-01 15:29:49
 */
@Api(tags = "住院申请接口")
@RestController
@RequestMapping("inhospital/applicationinhospital")
public class ApplicationInhospitalController {

    @Autowired
    private ApplicationInhospitalService applicationInhospitalService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("查询住院信息列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = applicationInhospitalService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("通过id查询住院信息")
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ApplicationInhospitalEntity applicationInhospital = applicationInhospitalService.getById(id);

        return R.ok().put("applicationInhospital", applicationInhospital);
    }

    /**
     * 保存
     */
    @ApiOperation("保存住院信息")
    @RequestMapping("/save")
    public R save(@RequestBody ApplicationInhospitalEntity applicationInhospital){
		applicationInhospitalService.save(applicationInhospital);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改住院信息列表")
    @RequestMapping("/update")
    public R update(@RequestBody ApplicationInhospitalEntity applicationInhospital){
		applicationInhospitalService.updateById(applicationInhospital);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除住院信息列表")
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		applicationInhospitalService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
